<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../js/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function(){
       $("#s1").change(function(){
	       $.ajax({
					url : "getSecondTypes",
					data : "parentId=" + $(this).val(),
					dataType : "json",
					success : function(data) {
						$("#s2").html("");
						$.each(data,function(i,item){
	                        $("#s2").append("<option value='"+item.id+"'>"+item.name+"</option>");
						});
					},
					error : function() {
						alert("请求错误!");
					}
				});
       });
    });
</script>
</head>
<body>
	<h3>添加一级分类</h3>
	<form action="saveGoodsType" method="post">
		<input type="hidden" name="level" value="1" /> 
		名称:<input type="text" name="name" /> 
		<input type="submit" value="提交" />
	</form>
	<h3>添加二级分类</h3>
	<form action="saveGoodsType" method="post">
		  <input type="hidden" name="level" value="2"/>
		     一级分类:<select name="parentId">
		         <c:forEach var="g" items="${list}">
		             <option value="${g.id}">${g.name}</option>
		         </c:forEach>
		     </select>
		     二级分类:<input type="text" name="name"/>
		     <input type="submit" value="提交"/>
	</form>
	<h3>添加三级分类</h3>
	<form action="saveGoodsType" method="post">
		  <input type="hidden" name="level" value="3"/>
			     一级分类:<select id="s1">
			     <option value="">请选择</option>
			         <c:forEach var="g" items="${list}">
			             <option value="${g.id}">${g.name}</option>
			         </c:forEach>
			     </select>
		   二级分类:<select name="parentId" id="s2">
		     <option value="">请选择</option>
		     
		 </select>
		   三级分类:<input type="text" name="name"/>
			    <input type="submit" value="提交"/>
	</form>
</body>
</html>